<!-- saved from url=(0014)about:internet -->
<pre class="code">
<span class="srcline"><span class="lineno"><a href="1,1" id="srcline1">  1</a></span><span class="line"><span class="keyword">function</span> <span class="var type0" id="S2T0U3">N</span> = geoid_height( <span class="var type0" id="S3T0U6">lat</span>, <span class="var type0" id="S4T0U7">lon</span>, <span class="var type0" id="S5T0U8">varargin</span> )</span></span>
<span class="srcline"><span class="lineno"><a href="1,2" id="srcline2">  2</a></span><span class="line"><span class="comment">%  GEOIDHEIGHT Implement a geopotential model to calculate geoid height</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,3" id="srcline3">  3</a></span><span class="line"><span class="comment">%   N = GEOIDHEIGHT( LAT, LON, MODEL ) calculates the geoid height as</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,4" id="srcline4">  4</a></span><span class="line"><span class="comment">%   determined from a selected geopotential model, MODEL. An array of M</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,5" id="srcline5">  5</a></span><span class="line"><span class="comment">%   geoid heights, N, are interpolated at M geocentric latitude, LAT, and M</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,6" id="srcline6">  6</a></span><span class="line"><span class="comment">%   geocentric longitude, LON, from a grid of point values in the tide-free</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,7" id="srcline7">  7</a></span><span class="line"><span class="comment">%   system, using the selected geopotential model, MODEL.  </span></span></span>
<span class="srcline"><span class="lineno"><a href="1,8" id="srcline8">  8</a></span><span class="line"><span class="comment">%</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,9" id="srcline9">  9</a></span><span class="line"><span class="comment">%   The GEOIDHEIGHT function calculates geoid heights to 0.01 meters for</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,10" id="srcline10"> 10</a></span><span class="line"><span class="comment">%   EGM96 and custom.  The GEOIDHEIGHT function calculates geoid heights to</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,11" id="srcline11"> 11</a></span><span class="line"><span class="comment">%   0.001 meters for EGM2008.</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,12" id="srcline12"> 12</a></span><span class="line"><span class="comment">% </span></span></span>
<span class="srcline"><span class="lineno"><a href="1,13" id="srcline13"> 13</a></span><span class="line"><span class="comment">%   The interpolation scheme wraps over the poles to allow for geoid height</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,14" id="srcline14"> 14</a></span><span class="line"><span class="comment">%   calculations at and near these locations.</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,15" id="srcline15"> 15</a></span><span class="line"><span class="comment">%</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,16" id="srcline16"> 16</a></span><span class="line"><span class="comment">%   Alternate formats for calling geoid height are:</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,17" id="srcline17"> 17</a></span><span class="line"><span class="comment">%   N = GEOIDHEIGHT( LAT, LON )</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,18" id="srcline18"> 18</a></span><span class="line"><span class="comment">%   N = GEOIDHEIGHT( LAT, LON, ACTION )</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,19" id="srcline19"> 19</a></span><span class="line"><span class="comment">%   N = GEOIDHEIGHT( LAT, LON, MODEL, ACTION )</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,20" id="srcline20"> 20</a></span><span class="line"><span class="comment">%   N = GEOIDHEIGHT( LAT, LON, 'Custom', DATAFILE )</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,21" id="srcline21"> 21</a></span><span class="line"><span class="comment">%   N = GEOIDHEIGHT( LAT, LON, 'Custom', DATAFILE, ACTION )</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,22" id="srcline22"> 22</a></span><span class="line"><span class="comment">%</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,23" id="srcline23"> 23</a></span><span class="line"><span class="comment">%   Inputs for GEOIDHEIGHT are:</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,24" id="srcline24"> 24</a></span><span class="line"><span class="comment">%   LAT      :an array of M geocentric latitudes in degrees where north</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,25" id="srcline25"> 25</a></span><span class="line"><span class="comment">%             latitude is positive, and south latitude is negative. LAT</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,26" id="srcline26"> 26</a></span><span class="line"><span class="comment">%             must be of type single or double. If LAT is not in the range</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,27" id="srcline27"> 27</a></span><span class="line"><span class="comment">%             of [-90,90] it is wrapped to be within the range.</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,28" id="srcline28"> 28</a></span><span class="line"><span class="comment">%   LON      :an array of M geocentric longitude in degrees where east</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,29" id="srcline29"> 29</a></span><span class="line"><span class="comment">%             longitude is positive, west is negative. LON must be of type</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,30" id="srcline30"> 30</a></span><span class="line"><span class="comment">%             single or double. If LON is not in the range of [0,360] it is</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,31" id="srcline31"> 31</a></span><span class="line"><span class="comment">%             wrapped to be within the range.</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,32" id="srcline32"> 32</a></span><span class="line"><span class="comment">%   MODEL    :a string specifying the geopotential model: 'EGM2008' (Earth),</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,33" id="srcline33"> 33</a></span><span class="line"><span class="comment">%             'EGM96' (Earth), or 'Custom'.  The default is 'EGM96'.  </span></span></span>
<span class="srcline"><span class="lineno"><a href="1,34" id="srcline34"> 34</a></span><span class="line"><span class="comment">%             'EGM96' uses a 15-minute grid of point values in the</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,35" id="srcline35"> 35</a></span><span class="line"><span class="comment">%             tide-free system, using EGM96 Geopotential Model to degree</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,36" id="srcline36"> 36</a></span><span class="line"><span class="comment">%             and order 360.  The EGM2008 MODEL uses a 2.5-minute grid of</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,37" id="srcline37"> 37</a></span><span class="line"><span class="comment">%             point values in the tide-free system, using the EGM2008</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,38" id="srcline38"> 38</a></span><span class="line"><span class="comment">%             Geopotential Model to degree and order 2159. The geoid</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,39" id="srcline39"> 39</a></span><span class="line"><span class="comment">%             undulations for EGM96 and EGM2008 are with respect to the</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,40" id="srcline40"> 40</a></span><span class="line"><span class="comment">%             WGS84 ellipsoid. </span></span></span>
<span class="srcline"><span class="lineno"><a href="1,41" id="srcline41"> 41</a></span><span class="line"><span class="comment">%   DATAFILE :a mat-file containing an array of geocentric</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,42" id="srcline42"> 42</a></span><span class="line"><span class="comment">%             latitude breakpoints, 'latbp', an array of geocentric</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,43" id="srcline43"> 43</a></span><span class="line"><span class="comment">%             longitude breakpoints, 'lonbp', a table of geoid height</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,44" id="srcline44"> 44</a></span><span class="line"><span class="comment">%             values,'grid' and a even integer scalar greater than 2 for</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,45" id="srcline45"> 45</a></span><span class="line"><span class="comment">%             number of interpolation points, 'windowSize'.  This is only</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,46" id="srcline46"> 46</a></span><span class="line"><span class="comment">%             needed for a 'Custom' geopotential model.     </span></span></span>
<span class="srcline"><span class="lineno"><a href="1,47" id="srcline47"> 47</a></span><span class="line"><span class="comment">%   ACTION   :a string to determine action for out of range latitude or</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,48" id="srcline48"> 48</a></span><span class="line"><span class="comment">%             longitude. Specify if out of range input invokes a 'Warning',</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,49" id="srcline49"> 49</a></span><span class="line"><span class="comment">%             'Error', or no action ('None'). The default is 'Warning'.</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,50" id="srcline50"> 50</a></span><span class="line"><span class="comment">%</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,51" id="srcline51"> 51</a></span><span class="line"><span class="comment">%   Output for GEOIDHEIGHT is:</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,52" id="srcline52"> 52</a></span><span class="line"><span class="comment">%   N        :an array of M geoid heights in meters with the same data type</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,53" id="srcline53"> 53</a></span><span class="line"><span class="comment">%             as the input LAT.</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,54" id="srcline54"> 54</a></span><span class="line"><span class="comment">%</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,55" id="srcline55"> 55</a></span><span class="line"><span class="comment">%   Limitations:</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,56" id="srcline56"> 56</a></span><span class="line"><span class="comment">%</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,57" id="srcline57"> 57</a></span><span class="line"><span class="comment">%   This function using the 'EGM96' MODEL has the limitations of the 1996</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,58" id="srcline58"> 58</a></span><span class="line"><span class="comment">%   Earth Geopotential Model.  For more information see the documentation.</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,59" id="srcline59"> 59</a></span><span class="line"><span class="comment">%</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,60" id="srcline60"> 60</a></span><span class="line"><span class="comment">%   The WGS84 EGM96 geoid undulations have an error range of +/- 0.5 to</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,61" id="srcline61"> 61</a></span><span class="line"><span class="comment">%   +/- 1.0 meters worldwide.</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,62" id="srcline62"> 62</a></span><span class="line"><span class="comment">%</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,63" id="srcline63"> 63</a></span><span class="line"><span class="comment">%   This function using the 'EGM2008' MODEL has the limitations of the 2008</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,64" id="srcline64"> 64</a></span><span class="line"><span class="comment">%   Earth Geopotential Model.  For more information see the documentation.</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,65" id="srcline65"> 65</a></span><span class="line"><span class="comment">%</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,66" id="srcline66"> 66</a></span><span class="line"><span class="comment">%   Examples:</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,67" id="srcline67"> 67</a></span><span class="line"><span class="comment">%</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,68" id="srcline68"> 68</a></span><span class="line"><span class="comment">%   Calculate the EGM96 geoid height at 42.4 degrees N latitude and 71.0 degrees </span></span></span>
<span class="srcline"><span class="lineno"><a href="1,69" id="srcline69"> 69</a></span><span class="line"><span class="comment">%   W longitude with warning actions:</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,70" id="srcline70"> 70</a></span><span class="line"><span class="comment">%       N = geoidheight( 42.4, -71.0 )</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,71" id="srcline71"> 71</a></span><span class="line"><span class="comment">%</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,72" id="srcline72"> 72</a></span><span class="line"><span class="comment">%   Calculate the EGM2008 geoid height at two different locations with</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,73" id="srcline73"> 73</a></span><span class="line"><span class="comment">%   error actions.</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,74" id="srcline74"> 74</a></span><span class="line"><span class="comment">%       N = geoidheight( [39.3, 33.4], [77.2, 36.5], 'egm2008','error')</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,75" id="srcline75"> 75</a></span><span class="line"><span class="comment">%</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,76" id="srcline76"> 76</a></span><span class="line"><span class="comment">%   Calculate a custom geoid height at two different locations with</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,77" id="srcline77"> 77</a></span><span class="line"><span class="comment">%   no actions.</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,78" id="srcline78"> 78</a></span><span class="line"><span class="comment">%       N = geoidheight( [39.3, 33.4], [-77.2, 36.5], 'custom', <span class="keyword">...</span></span></span></span>
<span class="srcline"><span class="lineno"><a href="1,79" id="srcline79"> 79</a></span><span class="line"><span class="comment">%           'geoidegm96grid','none')</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,80" id="srcline80"> 80</a></span><span class="line"><span class="comment">%</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,81" id="srcline81"> 81</a></span><span class="line"><span class="comment">%   Note: This function uses geoid data that can be obtained using the</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,82" id="srcline82"> 82</a></span><span class="line"><span class="comment">%   aeroDataPackage command.</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,83" id="srcline83"> 83</a></span><span class="line"><span class="comment">%</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,84" id="srcline84"> 84</a></span><span class="line"><span class="comment">%   See also GRAVITYWGS84, GRAVITYSPHERICALHARMONIC</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,85" id="srcline85"> 85</a></span><span class="line"></span></span>
<span class="srcline"><span class="lineno"><a href="1,86" id="srcline86"> 86</a></span><span class="line"><span class="comment">%   Copyright 2010-2013 The MathWorks, Inc.</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,87" id="srcline87"> 87</a></span><span class="line"></span></span>
<span class="srcline"><span class="lineno"><a href="1,88" id="srcline88"> 88</a></span><span class="line"><span class="comment">%   References:</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,89" id="srcline89"> 89</a></span><span class="line"><span class="comment">%   [1] NIMA TR8350.2: "Department of Defense World Geodetic System</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,90" id="srcline90"> 90</a></span><span class="line"><span class="comment">%       1984, Its Definition and Relationship with Local Geodetic Systems."</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,91" id="srcline91"> 91</a></span><span class="line"><span class="comment">%   [2] NASA/TP-1998-206861: "The Development of the Joint NASA GSFC and NIMA</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,92" id="srcline92"> 92</a></span><span class="line"><span class="comment">%       Geopotential Model EGM96"</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,93" id="srcline93"> 93</a></span><span class="line"><span class="comment">%   [3] Pavlis, N.K., S.A. Holmes, S.C. Kenyon, and J.K. Factor, "An Earth</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,94" id="srcline94"> 94</a></span><span class="line"><span class="comment">%       Gravitational Model to Degree 2160: EGM2008", presented at the 2008</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,95" id="srcline95"> 95</a></span><span class="line"><span class="comment">%       General Assembly of the European Geosciences Union, Vienna,</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,96" id="srcline96"> 96</a></span><span class="line"><span class="comment">%       Austria, April 13-18, 2008. </span></span></span>
<span class="srcline"><span class="lineno"><a href="1,97" id="srcline97"> 97</a></span><span class="line"><span class="comment">%   [4] Vallado, D. A., "Fundamentals of Astrodynamics and Applications",</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,98" id="srcline98"> 98</a></span><span class="line"><span class="comment">%       McGraw-Hill, New York, 1997.  </span></span></span>
<span class="srcline"><span class="lineno"><a href="1,99" id="srcline99"> 99</a></span><span class="line"><span class="comment">%</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,100" id="srcline100">100</a></span><span class="line"><span class="comment">%   National Geospatial-Intelligence Agency websites:</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,101" id="srcline101">101</a></span><span class="line"><span class="comment">%   http://earth-info.nga.mil/GandG/wgs84/gravitymod/egm96/egm96.html</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,102" id="srcline102">102</a></span><span class="line"><span class="comment">%   http://earth-info.nga.mil/GandG/wgs84/gravitymod/egm2008/egm08_wgs84.html</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,103" id="srcline103">103</a></span><span class="line"></span></span>
<span class="srcline"><span class="lineno"><a href="1,104" id="srcline104">104</a></span><span class="line"><span class="keyword">persistent</span> <span class="var type0" id="S6T0U10">astgeoiddata</span> <span class="var type0" id="S7T0U11">astgeoidCustomError</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,105" id="srcline105">105</a></span><span class="line"></span></span>
<span class="srcline"><span class="lineno"><a href="1,106" id="srcline106">106</a></span><span class="line">narginchk(2, 5);</span></span>
<span class="srcline"><span class="lineno"><a href="1,107" id="srcline107">107</a></span><span class="line"></span></span>
<span class="srcline"><span class="lineno"><a href="1,108" id="srcline108">108</a></span><span class="line">checkinputs();</span></span>
<span class="srcline"><span class="lineno"><a href="1,109" id="srcline109">109</a></span><span class="line"></span></span>
<span class="srcline"><span class="lineno"><a href="1,110" id="srcline110">110</a></span><span class="line"><span class="comment">% set default values</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,111" id="srcline111">111</a></span><span class="line"><span class="var type0" id="S10T0U22">model</span>  = <span class="string">'EGM96'</span>;</span></span>
<span class="srcline"><span class="lineno"><a href="1,112" id="srcline112">112</a></span><span class="line"><span class="var type0" id="S11T0U26">action</span> = <span class="string">'warning'</span>;</span></span>
<span class="srcline"><span class="lineno"><a href="1,113" id="srcline113">113</a></span><span class="line"><span class="var type0" id="S12T0U30">datafile</span> = <span class="string">'geoidegm96grid.mat'</span>;</span></span>
<span class="srcline"><span class="lineno"><a href="1,114" id="srcline114">114</a></span><span class="line"></span></span>
<span class="srcline"><span class="lineno"><a href="1,115" id="srcline115">115</a></span><span class="line"><span class="keyword">switch</span> nargin                                                              </span></span>
<span class="srcline"><span class="lineno"><a href="1,116" id="srcline116">116</a></span><span class="line">    <span class="keyword">case</span> 3</span></span>
<span class="srcline"><span class="lineno"><a href="1,117" id="srcline117">117</a></span><span class="line">        <span class="keyword">if</span> ~ischar( <span class="var type0" id="S5T0U43">varargin</span>{1} )</span></span>
<span class="srcline"><span class="lineno"><a href="1,118" id="srcline118">118</a></span><span class="line">            error(message(<span class="string">'aero:geoidheight:inputTypeVar3'</span>));</span></span>
<span class="srcline"><span class="lineno"><a href="1,119" id="srcline119">119</a></span><span class="line">        <span class="keyword">end</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,120" id="srcline120">120</a></span><span class="line">        <span class="keyword">if</span> strcmpi( <span class="var type0" id="S5T0U56">varargin</span>{1}, <span class="string">'custom'</span>)</span></span>
<span class="srcline"><span class="lineno"><a href="1,121" id="srcline121">121</a></span><span class="line">            narginchk(4, 5);</span></span>
<span class="srcline"><span class="lineno"><a href="1,122" id="srcline122">122</a></span><span class="line">        <span class="keyword">else</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,123" id="srcline123">123</a></span><span class="line">            <span class="comment">% check that the 2008 model is in the path   </span></span></span>
<span class="srcline"><span class="lineno"><a href="1,124" id="srcline124">124</a></span><span class="line">            checkegm2008( <span class="var type0" id="S5T0U69">varargin</span>{1} );</span></span>
<span class="srcline"><span class="lineno"><a href="1,125" id="srcline125">125</a></span><span class="line">            <span class="comment">% assign model or action</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,126" id="srcline126">126</a></span><span class="line">            modeloraction( <span class="var type0" id="S5T0U75">varargin</span>{1} );</span></span>
<span class="srcline"><span class="lineno"><a href="1,127" id="srcline127">127</a></span><span class="line">        <span class="keyword">end</span>       </span></span>
<span class="srcline"><span class="lineno"><a href="1,128" id="srcline128">128</a></span><span class="line">    <span class="keyword">case</span> 4</span></span>
<span class="srcline"><span class="lineno"><a href="1,129" id="srcline129">129</a></span><span class="line">        <span class="keyword">if</span> ~ischar( <span class="var type0" id="S5T0U86">varargin</span>{1} ) || ~ischar( <span class="var type0" id="S5T0U92">varargin</span>{2} ) </span></span>
<span class="srcline"><span class="lineno"><a href="1,130" id="srcline130">130</a></span><span class="line">            error(message(<span class="string">'aero:geoidheight:inputTypeVar4'</span>));</span></span>
<span class="srcline"><span class="lineno"><a href="1,131" id="srcline131">131</a></span><span class="line">        <span class="keyword">end</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,132" id="srcline132">132</a></span><span class="line">        <span class="keyword">if</span> strcmpi( <span class="var type0" id="S5T0U105">varargin</span>{1}, <span class="string">'custom'</span>)</span></span>
<span class="srcline"><span class="lineno"><a href="1,133" id="srcline133">133</a></span><span class="line">            <span class="comment">% custom model with datafile</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,134" id="srcline134">134</a></span><span class="line">            <span class="var type0" id="S10T0U110">model</span> = lower( <span class="var type0" id="S5T0U114">varargin</span>{1} );</span></span>
<span class="srcline"><span class="lineno"><a href="1,135" id="srcline135">135</a></span><span class="line">            <span class="var type0" id="S12T0U118">datafile</span> = <span class="var type0" id="S5T0U120">varargin</span>{2};</span></span>
<span class="srcline"><span class="lineno"><a href="1,136" id="srcline136">136</a></span><span class="line">        <span class="keyword">else</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,137" id="srcline137">137</a></span><span class="line">            <span class="comment">% check that the 2008 model is in the path   </span></span></span>
<span class="srcline"><span class="lineno"><a href="1,138" id="srcline138">138</a></span><span class="line">            checkegm2008( <span class="var type0" id="S5T0U127">varargin</span>{1} );</span></span>
<span class="srcline"><span class="lineno"><a href="1,139" id="srcline139">139</a></span><span class="line">            <span class="comment">% assign model and action</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,140" id="srcline140">140</a></span><span class="line">            checkmodel( <span class="var type0" id="S5T0U133">varargin</span>{1} );</span></span>
<span class="srcline"><span class="lineno"><a href="1,141" id="srcline141">141</a></span><span class="line">            checkaction( <span class="var type0" id="S5T0U139">varargin</span>{2} );</span></span>
<span class="srcline"><span class="lineno"><a href="1,142" id="srcline142">142</a></span><span class="line">        <span class="keyword">end</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,143" id="srcline143">143</a></span><span class="line">    <span class="keyword">case</span> 5</span></span>
<span class="srcline"><span class="lineno"><a href="1,144" id="srcline144">144</a></span><span class="line">        <span class="keyword">if</span> ~ischar( <span class="var type0" id="S5T0U151">varargin</span>{1} ) || ~ischar( <span class="var type0" id="S5T0U157">varargin</span>{2} ) || ~ischar( <span class="var type0" id="S5T0U163">varargin</span>{3} )</span></span>
<span class="srcline"><span class="lineno"><a href="1,145" id="srcline145">145</a></span><span class="line">            error(message(<span class="string">'aero:geoidheight:inputTypeVar5'</span>));</span></span>
<span class="srcline"><span class="lineno"><a href="1,146" id="srcline146">146</a></span><span class="line">        <span class="keyword">end</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,147" id="srcline147">147</a></span><span class="line">        <span class="comment">% set action for custom model with datafile</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,148" id="srcline148">148</a></span><span class="line">        <span class="keyword">if</span> strcmpi( <span class="var type0" id="S5T0U176">varargin</span>{1}, <span class="string">'custom'</span>)</span></span>
<span class="srcline"><span class="lineno"><a href="1,149" id="srcline149">149</a></span><span class="line">            <span class="comment">% custom model with datafile</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,150" id="srcline150">150</a></span><span class="line">            <span class="var type0" id="S10T0U181">model</span> = lower( <span class="var type0" id="S5T0U185">varargin</span>{1} );</span></span>
<span class="srcline"><span class="lineno"><a href="1,151" id="srcline151">151</a></span><span class="line">            <span class="var type0" id="S12T0U189">datafile</span> = <span class="var type0" id="S5T0U191">varargin</span>{2};</span></span>
<span class="srcline"><span class="lineno"><a href="1,152" id="srcline152">152</a></span><span class="line">            checkaction( <span class="var type0" id="S5T0U197">varargin</span>{3} );</span></span>
<span class="srcline"><span class="lineno"><a href="1,153" id="srcline153">153</a></span><span class="line">        <span class="keyword">else</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,154" id="srcline154">154</a></span><span class="line">            <span class="comment">% This option is only for 'custom'</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,155" id="srcline155">155</a></span><span class="line">            error(message(<span class="string">'aero:geoidheight:wrongModel'</span>));</span></span>
<span class="srcline"><span class="lineno"><a href="1,156" id="srcline156">156</a></span><span class="line">        <span class="keyword">end</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,157" id="srcline157">157</a></span><span class="line"><span class="keyword">end</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,158" id="srcline158">158</a></span><span class="line"></span></span>
<span class="srcline"><span class="lineno"><a href="1,159" id="srcline159">159</a></span><span class="line"><span class="var type0" id="S23T0U208">actionstr</span> = {<span class="string">'none'</span> <span class="string">'warning'</span> <span class="string">'error'</span>};</span></span>
<span class="srcline"><span class="lineno"><a href="1,160" id="srcline160">160</a></span><span class="line"><span class="var type0" id="S24T0U216">actionidx</span> = find(strcmp(<span class="var type0" id="S23T0U221">actionstr</span>, <span class="var type0" id="S11T0U222">action</span>));</span></span>
<span class="srcline"><span class="lineno"><a href="1,161" id="srcline161">161</a></span><span class="line"></span></span>
<span class="srcline"><span class="lineno"><a href="1,162" id="srcline162">162</a></span><span class="line">checklatitude();</span></span>
<span class="srcline"><span class="lineno"><a href="1,163" id="srcline163">163</a></span><span class="line">checklongitude();</span></span>
<span class="srcline"><span class="lineno"><a href="1,164" id="srcline164">164</a></span><span class="line"></span></span>
<span class="srcline"><span class="lineno"><a href="1,165" id="srcline165">165</a></span><span class="line"><span class="keyword">if</span> ( isempty(<span class="var type0" id="S6T0U237">astgeoiddata</span>) || ~strcmp( <span class="var type0" id="S6T0U242">astgeoiddata</span>.type, <span class="var type0" id="S10T0U244">model</span> ) || <span class="keyword">...</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,166" id="srcline166">166</a></span><span class="line">                   ~strcmpi( <span class="var type0" id="S6T0U249">astgeoiddata</span>.file, <span class="var type0" id="S12T0U251">datafile</span> ) || ~isempty(<span class="var type0" id="S7T0U255">astgeoidCustomError</span>))</span></span>
<span class="srcline"><span class="lineno"><a href="1,167" id="srcline167">167</a></span><span class="line">    <span class="comment">% data needs to be initialized</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,168" id="srcline168">168</a></span><span class="line">    <span class="keyword">try</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,169" id="srcline169">169</a></span><span class="line">        <span class="var type0" id="S6T0U259">astgeoiddata</span> = load(<span class="var type0" id="S12T0U262">datafile</span>);</span></span>
<span class="srcline"><span class="lineno"><a href="1,170" id="srcline170">170</a></span><span class="line">    <span class="keyword">catch</span> <span class="var type0" id="S31T0U264">MECustomFileLoad</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,171" id="srcline171">171</a></span><span class="line">        throwAsCaller(<span class="var type0" id="S31T0U268">MECustomFileLoad</span>)</span></span>
<span class="srcline"><span class="lineno"><a href="1,172" id="srcline172">172</a></span><span class="line">    <span class="keyword">end</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,173" id="srcline173">173</a></span><span class="line">    <span class="var type0" id="S6T0U272">astgeoiddata</span>.type = <span class="var type0" id="S10T0U274">model</span>;</span></span>
<span class="srcline"><span class="lineno"><a href="1,174" id="srcline174">174</a></span><span class="line">    <span class="var type0" id="S6T0U278">astgeoiddata</span>.file = <span class="var type0" id="S12T0U280">datafile</span>;</span></span>
<span class="srcline"><span class="lineno"><a href="1,175" id="srcline175">175</a></span><span class="line">    <span class="keyword">if</span> strcmp(<span class="string">'custom'</span>, <span class="var type0" id="S6T0U287">astgeoiddata</span>.type)</span></span>
<span class="srcline"><span class="lineno"><a href="1,176" id="srcline176">176</a></span><span class="line">        <span class="comment">% check for the existence of correct variables in mat-file</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,177" id="srcline177">177</a></span><span class="line">        <span class="var type0" id="S33T0U291">fieldsExist</span> = ~isfield(<span class="var type0" id="S6T0U295">astgeoiddata</span>,{<span class="string">'latbp'</span> <span class="string">'lonbp'</span> <span class="string">'grid'</span> <span class="string">'windowSize'</span>});</span></span>
<span class="srcline"><span class="lineno"><a href="1,178" id="srcline178">178</a></span><span class="line">        </span></span>
<span class="srcline"><span class="lineno"><a href="1,179" id="srcline179">179</a></span><span class="line">        <span class="var type0" id="S35T0U304">fhFields</span> = { @() disp(<span class="string">''</span>), <span class="keyword">...</span><span class="comment"> <span class="comment">% all fields exist</span></span></span></span>
<span class="srcline"><span class="lineno"><a href="1,180" id="srcline180">180</a></span><span class="line">            @() error(message(<span class="string">'aero:geoidheight:noLatitudeBP'</span>, <span class="var type0" id="S12T0U317">datafile</span>)), <span class="keyword">...</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,181" id="srcline181">181</a></span><span class="line">            @() error(message(<span class="string">'aero:geoidheight:noLongitudeBP'</span>, <span class="var type0" id="S12T0U324">datafile</span>)), <span class="keyword">...</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,182" id="srcline182">182</a></span><span class="line">            @() error(message(<span class="string">'aero:geoidheight:noGrid'</span>, <span class="var type0" id="S12T0U331">datafile</span>)), <span class="keyword">...</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,183" id="srcline183">183</a></span><span class="line">            @() error(message(<span class="string">'aero:geoidheight:noWindowSize'</span>, <span class="var type0" id="S12T0U338">datafile</span>))};</span></span>
<span class="srcline"><span class="lineno"><a href="1,184" id="srcline184">184</a></span><span class="line">        </span></span>
<span class="srcline"><span class="lineno"><a href="1,185" id="srcline185">185</a></span><span class="line">        <span class="var type0" id="S37T0U341">idx</span> = find(<span class="var type0" id="S33T0U344">fieldsExist</span>,1);</span></span>
<span class="srcline"><span class="lineno"><a href="1,186" id="srcline186">186</a></span><span class="line">        <span class="keyword">if</span> isempty(<span class="var type0" id="S37T0U350">idx</span>)</span></span>
<span class="srcline"><span class="lineno"><a href="1,187" id="srcline187">187</a></span><span class="line">            <span class="var type0" id="S37T0U353">idx</span> = 0;</span></span>
<span class="srcline"><span class="lineno"><a href="1,188" id="srcline188">188</a></span><span class="line">        <span class="keyword">end</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,189" id="srcline189">189</a></span><span class="line">        </span></span>
<span class="srcline"><span class="lineno"><a href="1,190" id="srcline190">190</a></span><span class="line">        <span class="comment">% allow same custom filename to run through check if had previous error</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,191" id="srcline191">191</a></span><span class="line">        <span class="var type0" id="S7T0U357">astgeoidCustomError</span> = 1;</span></span>
<span class="srcline"><span class="lineno"><a href="1,192" id="srcline192">192</a></span><span class="line">        </span></span>
<span class="srcline"><span class="lineno"><a href="1,193" id="srcline193">193</a></span><span class="line">        <span class="comment">% Call appropriate function</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,194" id="srcline194">194</a></span><span class="line">        <span class="var type0" id="S35T0U362">fhFields</span>{<span class="var type0" id="S37T0U364">idx</span>+1}()    </span></span>
<span class="srcline"><span class="lineno"><a href="1,195" id="srcline195">195</a></span><span class="line">        </span></span>
<span class="srcline"><span class="lineno"><a href="1,196" id="srcline196">196</a></span><span class="line">        <span class="comment">% check data type and sizes of custom data</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,197" id="srcline197">197</a></span><span class="line">        <span class="keyword">if</span>  ~isnumeric( <span class="var type0" id="S6T0U375">astgeoiddata</span>.latbp ) || ~isnumeric( <span class="var type0" id="S6T0U381">astgeoiddata</span>.lonbp ) || <span class="keyword">...</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,198" id="srcline198">198</a></span><span class="line">                ~isnumeric( <span class="var type0" id="S6T0U387">astgeoiddata</span>.grid ) || ~isnumeric( <span class="var type0" id="S6T0U393">astgeoiddata</span>.windowSize )</span></span>
<span class="srcline"><span class="lineno"><a href="1,199" id="srcline199">199</a></span><span class="line">            error(message(<span class="string">'aero:geoidheight:notNumeric'</span>))</span></span>
<span class="srcline"><span class="lineno"><a href="1,200" id="srcline200">200</a></span><span class="line">        <span class="keyword">end</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,201" id="srcline201">201</a></span><span class="line">        <span class="keyword">if</span>  ~isscalar( <span class="var type0" id="S6T0U407">astgeoiddata</span>.windowSize )</span></span>
<span class="srcline"><span class="lineno"><a href="1,202" id="srcline202">202</a></span><span class="line">            error(message(<span class="string">'aero:geoidheight:notScalar'</span>))</span></span>
<span class="srcline"><span class="lineno"><a href="1,203" id="srcline203">203</a></span><span class="line">        <span class="keyword">end</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,204" id="srcline204">204</a></span><span class="line">        <span class="keyword">if</span>  ~isvector( <span class="var type0" id="S6T0U422">astgeoiddata</span>.latbp ) || ~isvector( <span class="var type0" id="S6T0U428">astgeoiddata</span>.lonbp ) </span></span>
<span class="srcline"><span class="lineno"><a href="1,205" id="srcline205">205</a></span><span class="line">            error(message(<span class="string">'aero:geoidheight:not1DArray'</span>))</span></span>
<span class="srcline"><span class="lineno"><a href="1,206" id="srcline206">206</a></span><span class="line">        <span class="keyword">end</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,207" id="srcline207">207</a></span><span class="line">         <span class="keyword">if</span> ~all( size( <span class="var type0" id="S6T0U445">astgeoiddata</span>.grid ) == [ numel(<span class="var type0" id="S6T0U452">astgeoiddata</span>.latbp) numel(<span class="var type0" id="S6T0U457">astgeoiddata</span>.lonbp) ] ) </span></span>
<span class="srcline"><span class="lineno"><a href="1,208" id="srcline208">208</a></span><span class="line">            error(message(<span class="string">'aero:geoidheight:wrongMatrixSize'</span>))</span></span>
<span class="srcline"><span class="lineno"><a href="1,209" id="srcline209">209</a></span><span class="line">        <span class="keyword">end</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,210" id="srcline210">210</a></span><span class="line">        <span class="keyword">if</span>  any(~isfinite( <span class="var type0" id="S6T0U476">astgeoiddata</span>.latbp )) || any(~isfinite( <span class="var type0" id="S6T0U484">astgeoiddata</span>.lonbp )) || <span class="keyword">...</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,211" id="srcline211">211</a></span><span class="line">             any(any(~isfinite( <span class="var type0" id="S6T0U494">astgeoiddata</span>.grid ))) || any(~isfinite( <span class="var type0" id="S6T0U502">astgeoiddata</span>.windowSize ))</span></span>
<span class="srcline"><span class="lineno"><a href="1,212" id="srcline212">212</a></span><span class="line">            error(message(<span class="string">'aero:geoidheight:notFinite'</span>))</span></span>
<span class="srcline"><span class="lineno"><a href="1,213" id="srcline213">213</a></span><span class="line">        <span class="keyword">end</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,214" id="srcline214">214</a></span><span class="line">        <span class="keyword">if</span> (mod(<span class="var type0" id="S6T0U517">astgeoiddata</span>.windowSize,2) || (<span class="var type0" id="S6T0U523">astgeoiddata</span>.windowSize &lt;= 2))</span></span>
<span class="srcline"><span class="lineno"><a href="1,215" id="srcline215">215</a></span><span class="line">            error(message(<span class="string">'aero:geoidheight:notEvenInteger'</span>))</span></span>
<span class="srcline"><span class="lineno"><a href="1,216" id="srcline216">216</a></span><span class="line">        <span class="keyword">end</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,217" id="srcline217">217</a></span><span class="line">        <span class="comment">% successful custom file read</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,218" id="srcline218">218</a></span><span class="line">        <span class="var type0" id="S7T0U534">astgeoidCustomError</span> = [];</span></span>
<span class="srcline"><span class="lineno"><a href="1,219" id="srcline219">219</a></span><span class="line">     <span class="keyword">end</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,220" id="srcline220">220</a></span><span class="line"><span class="keyword">end</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,221" id="srcline221">221</a></span><span class="line"></span></span>
<span class="srcline"><span class="lineno"><a href="1,222" id="srcline222">222</a></span><span class="line"><span class="comment">% checkinputs above should ensure lat and lon are of equal dimension</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,223" id="srcline223">223</a></span><span class="line"><span class="var type0" id="S47T0U539">n</span> = numel(<span class="var type0" id="S3T0U542">lat</span>);</span></span>
<span class="srcline"><span class="lineno"><a href="1,224" id="srcline224">224</a></span><span class="line"></span></span>
<span class="srcline"><span class="lineno"><a href="1,225" id="srcline225">225</a></span><span class="line"><span class="comment">% Preallocate</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,226" id="srcline226">226</a></span><span class="line"><span class="var type0" id="S2T0U545">N</span>  = zeros(1,<span class="var type0" id="S47T0U549">n</span>,<span class="string">'single'</span>);</span></span>
<span class="srcline"><span class="lineno"><a href="1,227" id="srcline227">227</a></span><span class="line"></span></span>
<span class="srcline"><span class="lineno"><a href="1,228" id="srcline228">228</a></span><span class="line"><span class="var type0" id="S49T0U553">halfWindowSize</span> = <span class="var type0" id="S6T0U556">astgeoiddata</span>.windowSize/2;</span></span>
<span class="srcline"><span class="lineno"><a href="1,229" id="srcline229">229</a></span><span class="line"></span></span>
<span class="srcline"><span class="lineno"><a href="1,230" id="srcline230">230</a></span><span class="line"><span class="comment">% Get lat data type to set output later</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,231" id="srcline231">231</a></span><span class="line"><span class="var type0" id="S50T0U561">latType</span> = class(<span class="var type0" id="S3T0U564">lat</span>);</span></span>
<span class="srcline"><span class="lineno"><a href="1,232" id="srcline232">232</a></span><span class="line"></span></span>
<span class="srcline"><span class="lineno"><a href="1,233" id="srcline233">233</a></span><span class="line"><span class="comment">% Convert to single for interpolation</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,234" id="srcline234">234</a></span><span class="line"><span class="keyword">if</span> ~isa(<span class="var type0" id="S50T0U570">latType</span>,<span class="string">'single'</span>)</span></span>
<span class="srcline"><span class="lineno"><a href="1,235" id="srcline235">235</a></span><span class="line">    <span class="var type0" id="S3T0U574">lat</span> = single(<span class="var type0" id="S3T0U577">lat</span>);</span></span>
<span class="srcline"><span class="lineno"><a href="1,236" id="srcline236">236</a></span><span class="line">    <span class="var type0" id="S4T0U580">lon</span> = single(<span class="var type0" id="S4T0U583">lon</span>);</span></span>
<span class="srcline"><span class="lineno"><a href="1,237" id="srcline237">237</a></span><span class="line"><span class="keyword">end</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,238" id="srcline238">238</a></span><span class="line"></span></span>
<span class="srcline"><span class="lineno"><a href="1,239" id="srcline239">239</a></span><span class="line"><span class="comment">% Loop through all of the lon/lat input pairs</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,240" id="srcline240">240</a></span><span class="line"><span class="keyword">for</span> <span class="var type0" id="S54T0U586">k</span> = 1:<span class="var type0" id="S47T0U589">n</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,241" id="srcline241">241</a></span><span class="line">    <span class="comment">% Find indices for window of height data. If there is an exact match,</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,242" id="srcline242">242</a></span><span class="line">    <span class="comment">% it will be in the middle of the window (i.e. vector will be of size</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,243" id="srcline243">243</a></span><span class="line">    <span class="comment">% windowSize+1-by-windowsize+1 with matching index in the middle).</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,244" id="srcline244">244</a></span><span class="line">    <span class="var type0" id="S55T0U592">lonbpi</span> = [find(<span class="var type0" id="S6T0U599">astgeoiddata</span>.lonbp&lt;<span class="var type0" id="S4T0U602">lon</span>(<span class="var type0" id="S54T0U603">k</span>),<span class="var type0" id="S49T0U604">halfWindowSize</span>,<span class="string">'last'</span>), <span class="keyword">...</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,245" id="srcline245">245</a></span><span class="line">        find(<span class="var type0" id="S6T0U610">astgeoiddata</span>.lonbp==<span class="var type0" id="S4T0U613">lon</span>(<span class="var type0" id="S54T0U614">k</span>)), <span class="keyword">...</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,246" id="srcline246">246</a></span><span class="line">        find(<span class="var type0" id="S6T0U619">astgeoiddata</span>.lonbp&gt;<span class="var type0" id="S4T0U622">lon</span>(<span class="var type0" id="S54T0U623">k</span>),<span class="var type0" id="S49T0U624">halfWindowSize</span>,<span class="string">'first'</span>)];</span></span>
<span class="srcline"><span class="lineno"><a href="1,247" id="srcline247">247</a></span><span class="line">    <span class="var type0" id="S56T0U628">latbpi</span> = [find(<span class="var type0" id="S6T0U635">astgeoiddata</span>.latbp&lt;<span class="var type0" id="S3T0U638">lat</span>(<span class="var type0" id="S54T0U639">k</span>),<span class="var type0" id="S49T0U640">halfWindowSize</span>,<span class="string">'last'</span>), <span class="keyword">...</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,248" id="srcline248">248</a></span><span class="line">        find(<span class="var type0" id="S6T0U646">astgeoiddata</span>.latbp==<span class="var type0" id="S3T0U649">lat</span>(<span class="var type0" id="S54T0U650">k</span>)), <span class="keyword">...</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,249" id="srcline249">249</a></span><span class="line">        find(<span class="var type0" id="S6T0U655">astgeoiddata</span>.latbp&gt;<span class="var type0" id="S3T0U658">lat</span>(<span class="var type0" id="S54T0U659">k</span>),<span class="var type0" id="S49T0U660">halfWindowSize</span>,<span class="string">'first'</span>)];</span></span>
<span class="srcline"><span class="lineno"><a href="1,250" id="srcline250">250</a></span><span class="line"></span></span>
<span class="srcline"><span class="lineno"><a href="1,251" id="srcline251">251</a></span><span class="line">    <span class="comment">% As mentioned above, if there are windowSize+1 elements in lonbpi, the</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,252" id="srcline252">252</a></span><span class="line">    <span class="comment">% middle value is the index for an exact value of lon.</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,253" id="srcline253">253</a></span><span class="line">    <span class="keyword">if</span> numel(<span class="var type0" id="S55T0U667">lonbpi</span>) == <span class="var type0" id="S6T0U670">astgeoiddata</span>.windowSize+1</span></span>
<span class="srcline"><span class="lineno"><a href="1,254" id="srcline254">254</a></span><span class="line">        <span class="comment">% Pull out the lat window values for the exact lon value.</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,255" id="srcline255">255</a></span><span class="line">        <span class="var type0" id="S57T0U675">latsforlon</span> = <span class="var type0" id="S6T0U678">astgeoiddata</span>.grid(<span class="var type0" id="S56T0U680">latbpi</span>,<span class="var type0" id="S55T0U682">lonbpi</span>(<span class="var type0" id="S6T0U686">astgeoiddata</span>.windowSize/2 + 1));</span></span>
<span class="srcline"><span class="lineno"><a href="1,256" id="srcline256">256</a></span><span class="line"></span></span>
<span class="srcline"><span class="lineno"><a href="1,257" id="srcline257">257</a></span><span class="line">        <span class="comment">% Otherwise perform interpolation to find height values for given lon</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,258" id="srcline258">258</a></span><span class="line">        <span class="comment">% at each lat in window.</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,259" id="srcline259">259</a></span><span class="line">    <span class="keyword">else</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,260" id="srcline260">260</a></span><span class="line">        <span class="comment">% This transpose is here because interp1 will interp down each</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,261" id="srcline261">261</a></span><span class="line">        <span class="comment">% column of the input matrix, and in this instance we want it to</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,262" id="srcline262">262</a></span><span class="line">        <span class="comment">% interp across each row of grid(latbpi,lonbpi).</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,263" id="srcline263">263</a></span><span class="line">        <span class="var type0" id="S57T0U693">latsforlon</span> = interp1(<span class="var type0" id="S6T0U698">astgeoiddata</span>.lonbp(<span class="var type0" id="S55T0U700">lonbpi</span>),<span class="var type0" id="S6T0U704">astgeoiddata</span>.grid(<span class="var type0" id="S56T0U706">latbpi</span>,<span class="var type0" id="S55T0U707">lonbpi</span>)',<span class="var type0" id="S4T0U709">lon</span>(<span class="var type0" id="S54T0U710">k</span>),<span class="string">'spline'</span>);</span></span>
<span class="srcline"><span class="lineno"><a href="1,264" id="srcline264">264</a></span><span class="line">    <span class="keyword">end</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,265" id="srcline265">265</a></span><span class="line"></span></span>
<span class="srcline"><span class="lineno"><a href="1,266" id="srcline266">266</a></span><span class="line">    <span class="comment">% As mentioned above, if there are windowSize+1 elements in latbpi, the</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,267" id="srcline267">267</a></span><span class="line">    <span class="comment">% middle value is the index for an exact value of lat.</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,268" id="srcline268">268</a></span><span class="line">    <span class="keyword">if</span> numel(<span class="var type0" id="S56T0U717">latbpi</span>) == <span class="var type0" id="S6T0U720">astgeoiddata</span>.windowSize+1</span></span>
<span class="srcline"><span class="lineno"><a href="1,269" id="srcline269">269</a></span><span class="line">        <span class="comment">% Pull out the height value for exact value of lat from range of</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,270" id="srcline270">270</a></span><span class="line">        <span class="comment">% height possibilities determined above from lon.</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,271" id="srcline271">271</a></span><span class="line">        <span class="var type0" id="S2T0U726">N</span>(<span class="var type0" id="S54T0U727">k</span>) = <span class="var type0" id="S57T0U729">latsforlon</span>(<span class="var type0" id="S49T0U731">halfWindowSize</span> + 1);</span></span>
<span class="srcline"><span class="lineno"><a href="1,272" id="srcline272">272</a></span><span class="line"></span></span>
<span class="srcline"><span class="lineno"><a href="1,273" id="srcline273">273</a></span><span class="line">        <span class="comment">% Otherwise perform interpolation to find height value.</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,274" id="srcline274">274</a></span><span class="line">    <span class="keyword">else</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,275" id="srcline275">275</a></span><span class="line">        <span class="var type0" id="S2T0U737">N</span>(<span class="var type0" id="S54T0U738">k</span>) = interp1(<span class="var type0" id="S6T0U743">astgeoiddata</span>.latbp(<span class="var type0" id="S56T0U745">latbpi</span>),<span class="var type0" id="S57T0U746">latsforlon</span>,<span class="var type0" id="S3T0U748">lat</span>(<span class="var type0" id="S54T0U749">k</span>),<span class="string">'spline'</span>);</span></span>
<span class="srcline"><span class="lineno"><a href="1,276" id="srcline276">276</a></span><span class="line">    <span class="keyword">end</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,277" id="srcline277">277</a></span><span class="line"><span class="keyword">end</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,278" id="srcline278">278</a></span><span class="line"></span></span>
<span class="srcline"><span class="lineno"><a href="1,279" id="srcline279">279</a></span><span class="line"><span class="comment">% Expand to double for unit changes and truncating.</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,280" id="srcline280">280</a></span><span class="line"><span class="var type0" id="S2T0U753">N</span> = double(<span class="var type0" id="S2T0U756">N</span>);</span></span>
<span class="srcline"><span class="lineno"><a href="1,281" id="srcline281">281</a></span><span class="line"></span></span>
<span class="srcline"><span class="lineno"><a href="1,282" id="srcline282">282</a></span><span class="line"><span class="keyword">if</span> strcmp(<span class="var type0" id="S6T0U762">astgeoiddata</span>.type,<span class="string">'egm2008'</span>)</span></span>
<span class="srcline"><span class="lineno"><a href="1,283" id="srcline283">283</a></span><span class="line">    <span class="var type0" id="S2T0U767">N</span> = fix(<span class="var type0" id="S2T0U772">N</span>.*1000)*0.001;</span></span>
<span class="srcline"><span class="lineno"><a href="1,284" id="srcline284">284</a></span><span class="line"><span class="keyword">else</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,285" id="srcline285">285</a></span><span class="line">    <span class="var type0" id="S2T0U778">N</span> = fix(<span class="var type0" id="S2T0U783">N</span>.*100)*0.01;</span></span>
<span class="srcline"><span class="lineno"><a href="1,286" id="srcline286">286</a></span><span class="line"><span class="keyword">end</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,287" id="srcline287">287</a></span><span class="line"></span></span>
<span class="srcline"><span class="lineno"><a href="1,288" id="srcline288">288</a></span><span class="line"><span class="comment">% Cast to desired output data type</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,289" id="srcline289">289</a></span><span class="line"><span class="var type0" id="S2T0U788">N</span> = cast(<span class="var type0" id="S2T0U791">N</span>,<span class="var type0" id="S50T0U792">latType</span>);</span></span>
<span class="srcline"><span class="lineno"><a href="1,290" id="srcline290">290</a></span><span class="line"></span></span>
<span class="srcline"><span class="lineno"><a href="1,291" id="srcline291">291</a></span><span class="line"><span class="comment">%=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,292" id="srcline292">292</a></span><span class="line">    <span class="keyword">function</span> <span class="message fatal" id="M1F1C">checkinputs</span>()</span></span>
<span class="srcline"><span class="lineno"><a href="1,293" id="srcline293">293</a></span><span class="line">        <span class="keyword">if</span> ~isnumeric(<span class="var type0" id="S3T0U802">lat</span>)</span></span>
<span class="srcline"><span class="lineno"><a href="1,294" id="srcline294">294</a></span><span class="line">            <span class="comment">% Latitude should be a numeric array.  Otherwise error.</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,295" id="srcline295">295</a></span><span class="line">            error(message(<span class="string">'aero:geoidheight:latitudeNotNumeric'</span>));</span></span>
<span class="srcline"><span class="lineno"><a href="1,296" id="srcline296">296</a></span><span class="line">        <span class="keyword">end</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,297" id="srcline297">297</a></span><span class="line">        <span class="keyword">if</span> ~isnumeric(<span class="var type0" id="S4T0U814">lon</span>)</span></span>
<span class="srcline"><span class="lineno"><a href="1,298" id="srcline298">298</a></span><span class="line">            <span class="comment">% Altitude should be a numeric array.  Otherwise error.</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,299" id="srcline299">299</a></span><span class="line">            error(message(<span class="string">'aero:geoidheight:longitudeNotNumeric'</span>));</span></span>
<span class="srcline"><span class="lineno"><a href="1,300" id="srcline300">300</a></span><span class="line">        <span class="keyword">end</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,301" id="srcline301">301</a></span><span class="line">        <span class="keyword">if</span> ~all(size(<span class="var type0" id="S3T0U829">lat</span>) == size(<span class="var type0" id="S4T0U832">lon</span>))</span></span>
<span class="srcline"><span class="lineno"><a href="1,302" id="srcline302">302</a></span><span class="line">            error(message(<span class="string">'aero:geoidheight:arraySize'</span>));</span></span>
<span class="srcline"><span class="lineno"><a href="1,303" id="srcline303">303</a></span><span class="line">        <span class="keyword">end</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,304" id="srcline304">304</a></span><span class="line">        <span class="keyword">if</span> ~isfloat(<span class="var type0" id="S3T0U845">lat</span>) || ~isfloat(<span class="var type0" id="S4T0U849">lon</span>)</span></span>
<span class="srcline"><span class="lineno"><a href="1,305" id="srcline305">305</a></span><span class="line">            error(message(<span class="string">'aero:geoidheight:notFloat'</span>));</span></span>
<span class="srcline"><span class="lineno"><a href="1,306" id="srcline306">306</a></span><span class="line">        <span class="keyword">end</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,307" id="srcline307">307</a></span><span class="line">        <span class="keyword">if</span> ~strcmpi(class(<span class="var type0" id="S3T0U863">lat</span>),class(<span class="var type0" id="S4T0U866">lon</span>))</span></span>
<span class="srcline"><span class="lineno"><a href="1,308" id="srcline308">308</a></span><span class="line">            error(message(<span class="string">'aero:geoidheight:differentInputType'</span>));</span></span>
<span class="srcline"><span class="lineno"><a href="1,309" id="srcline309">309</a></span><span class="line">        <span class="keyword">end</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,310" id="srcline310">310</a></span><span class="line">    <span class="keyword">end</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,311" id="srcline311">311</a></span><span class="line"><span class="comment">%=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,312" id="srcline312">312</a></span><span class="line">    <span class="keyword">function</span> checklatitude()</span></span>
<span class="srcline"><span class="lineno"><a href="1,313" id="srcline313">313</a></span><span class="line">        <span class="comment">% Wrap latitude and longitude if necessary</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,314" id="srcline314">314</a></span><span class="line">        [<span class="var type0" id="S72T0U880">latwrapped</span>,<span class="var type0" id="S3T0U881">lat</span>,<span class="var type0" id="S4T0U882">lon</span>] = wraplatitude(<span class="var type0" id="S3T0U885">lat</span>,<span class="var type0" id="S4T0U886">lon</span>,<span class="string">'deg'</span>);</span></span>
<span class="srcline"><span class="lineno"><a href="1,315" id="srcline315">315</a></span><span class="line">        <span class="keyword">if</span> <span class="var type0" id="S72T0U890">latwrapped</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,316" id="srcline316">316</a></span><span class="line">            <span class="comment">% Create function handle array to handle messages based on</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,317" id="srcline317">317</a></span><span class="line">            <span class="comment">% action</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,318" id="srcline318">318</a></span><span class="line">            <span class="var type0" id="S76T0U893">fhlat</span> = {@() disp(<span class="string">''</span>)<span class="keyword">...</span><span class="comment"> <span class="comment">% do nothing for 'none'</span></span></span></span>
<span class="srcline"><span class="lineno"><a href="1,319" id="srcline319">319</a></span><span class="line">                  @() warning(message(<span class="string">'aero:geoidheight:warnLatitudeWrap'</span>)), <span class="keyword">...</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,320" id="srcline320">320</a></span><span class="line">                  @() error(message(<span class="string">'aero:geoidheight:latitudeWrap'</span>))};</span></span>
<span class="srcline"><span class="lineno"><a href="1,321" id="srcline321">321</a></span><span class="line">            </span></span>
<span class="srcline"><span class="lineno"><a href="1,322" id="srcline322">322</a></span><span class="line">           <span class="comment">% Call appropriate function</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,323" id="srcline323">323</a></span><span class="line">           <span class="var type0" id="S76T0U915">fhlat</span>{<span class="var type0" id="S24T0U916">actionidx</span>}()</span></span>
<span class="srcline"><span class="lineno"><a href="1,324" id="srcline324">324</a></span><span class="line">        <span class="keyword">end</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,325" id="srcline325">325</a></span><span class="line">    <span class="keyword">end</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,326" id="srcline326">326</a></span><span class="line"></span></span>
<span class="srcline"><span class="lineno"><a href="1,327" id="srcline327">327</a></span><span class="line"><span class="comment">%=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,328" id="srcline328">328</a></span><span class="line">    <span class="keyword">function</span> checklongitude()</span></span>
<span class="srcline"><span class="lineno"><a href="1,329" id="srcline329">329</a></span><span class="line">        [<span class="var type0" id="S82T0U924">lonwrapped</span>, <span class="var type0" id="S4T0U925">lon</span>] = wraplongitude(<span class="var type0" id="S4T0U928">lon</span>,<span class="string">'deg'</span>,<span class="string">'360'</span>);</span></span>
<span class="srcline"><span class="lineno"><a href="1,330" id="srcline330">330</a></span><span class="line"></span></span>
<span class="srcline"><span class="lineno"><a href="1,331" id="srcline331">331</a></span><span class="line">        <span class="keyword">if</span> <span class="var type0" id="S82T0U933">lonwrapped</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,332" id="srcline332">332</a></span><span class="line">            <span class="comment">% Create function handle array to handle messages based on</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,333" id="srcline333">333</a></span><span class="line">            <span class="comment">% action</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,334" id="srcline334">334</a></span><span class="line">            <span class="var type0" id="S85T0U936">fhlon</span> = {@() disp(<span class="string">''</span>)<span class="keyword">...</span><span class="comment"> <span class="comment">% do nothing for 'none'</span></span></span></span>
<span class="srcline"><span class="lineno"><a href="1,335" id="srcline335">335</a></span><span class="line">                @() warning(message(<span class="string">'aero:geoidheight:warnLongitudeWrap'</span>)), <span class="keyword">...</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,336" id="srcline336">336</a></span><span class="line">                @() error(message(<span class="string">'aero:geoidheight:longitudeWrap'</span>))};</span></span>
<span class="srcline"><span class="lineno"><a href="1,337" id="srcline337">337</a></span><span class="line"></span></span>
<span class="srcline"><span class="lineno"><a href="1,338" id="srcline338">338</a></span><span class="line">            <span class="comment">% Call appropriate function</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,339" id="srcline339">339</a></span><span class="line">            <span class="var type0" id="S85T0U958">fhlon</span>{<span class="var type0" id="S24T0U959">actionidx</span>}()</span></span>
<span class="srcline"><span class="lineno"><a href="1,340" id="srcline340">340</a></span><span class="line">        <span class="keyword">end</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,341" id="srcline341">341</a></span><span class="line">    <span class="keyword">end</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,342" id="srcline342">342</a></span><span class="line"><span class="comment">%=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,343" id="srcline343">343</a></span><span class="line">    <span class="keyword">function</span> checkmodel( <span class="var type0" id="S91T0U964">str</span> )</span></span>
<span class="srcline"><span class="lineno"><a href="1,344" id="srcline344">344</a></span><span class="line">        <span class="keyword">switch</span> lower( <span class="var type0" id="S91T0U968">str</span> )</span></span>
<span class="srcline"><span class="lineno"><a href="1,345" id="srcline345">345</a></span><span class="line">            <span class="keyword">case</span> <span class="string">'egm2008'</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,346" id="srcline346">346</a></span><span class="line">                <span class="var type0" id="S10T0U973">model</span> = lower( <span class="var type0" id="S91T0U976">str</span> );</span></span>
<span class="srcline"><span class="lineno"><a href="1,347" id="srcline347">347</a></span><span class="line">                <span class="var type0" id="S12T0U979">datafile</span> = <span class="string">'geoidegm2008grid.mat'</span>;</span></span>
<span class="srcline"><span class="lineno"><a href="1,348" id="srcline348">348</a></span><span class="line">            <span class="keyword">case</span> <span class="string">'egm96'</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,349" id="srcline349">349</a></span><span class="line">                <span class="var type0" id="S10T0U985">model</span> = lower( <span class="var type0" id="S91T0U988">str</span> );</span></span>
<span class="srcline"><span class="lineno"><a href="1,350" id="srcline350">350</a></span><span class="line">                <span class="var type0" id="S12T0U991">datafile</span> = <span class="string">'geoidegm96grid.mat'</span>;</span></span>
<span class="srcline"><span class="lineno"><a href="1,351" id="srcline351">351</a></span><span class="line">            <span class="keyword">otherwise</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,352" id="srcline352">352</a></span><span class="line">                error(message(<span class="string">'aero:geoidheight:unknownModel'</span>));</span></span>
<span class="srcline"><span class="lineno"><a href="1,353" id="srcline353">353</a></span><span class="line">        <span class="keyword">end</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,354" id="srcline354">354</a></span><span class="line">    <span class="keyword">end</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,355" id="srcline355">355</a></span><span class="line"><span class="comment">%=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,356" id="srcline356">356</a></span><span class="line">    <span class="keyword">function</span> checkaction( <span class="var type0" id="S97T0U1004">str</span> )</span></span>
<span class="srcline"><span class="lineno"><a href="1,357" id="srcline357">357</a></span><span class="line">        <span class="keyword">switch</span> lower( <span class="var type0" id="S97T0U1008">str</span> )</span></span>
<span class="srcline"><span class="lineno"><a href="1,358" id="srcline358">358</a></span><span class="line">            <span class="keyword">case</span> { <span class="string">'error'</span>, <span class="string">'warning'</span>, <span class="string">'none'</span> }</span></span>
<span class="srcline"><span class="lineno"><a href="1,359" id="srcline359">359</a></span><span class="line">                <span class="var type0" id="S11T0U1017">action</span> = lower( <span class="var type0" id="S97T0U1020">str</span> );</span></span>
<span class="srcline"><span class="lineno"><a href="1,360" id="srcline360">360</a></span><span class="line">            <span class="keyword">otherwise</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,361" id="srcline361">361</a></span><span class="line">                error(message(<span class="string">'aero:geoidheight:unknownAction'</span>));</span></span>
<span class="srcline"><span class="lineno"><a href="1,362" id="srcline362">362</a></span><span class="line">        <span class="keyword">end</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,363" id="srcline363">363</a></span><span class="line">    <span class="keyword">end</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,364" id="srcline364">364</a></span><span class="line"><span class="comment">%=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,365" id="srcline365">365</a></span><span class="line">    <span class="keyword">function</span> modeloraction( <span class="var type0" id="S102T0U1032">str</span> )</span></span>
<span class="srcline"><span class="lineno"><a href="1,366" id="srcline366">366</a></span><span class="line">        <span class="keyword">switch</span> lower( <span class="var type0" id="S102T0U1036">str</span> )</span></span>
<span class="srcline"><span class="lineno"><a href="1,367" id="srcline367">367</a></span><span class="line">            <span class="keyword">case</span> <span class="string">'egm2008'</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,368" id="srcline368">368</a></span><span class="line">                <span class="var type0" id="S10T0U1041">model</span> = lower( <span class="var type0" id="S102T0U1044">str</span> );</span></span>
<span class="srcline"><span class="lineno"><a href="1,369" id="srcline369">369</a></span><span class="line">                <span class="var type0" id="S12T0U1047">datafile</span> = <span class="string">'geoidegm2008grid.mat'</span>;</span></span>
<span class="srcline"><span class="lineno"><a href="1,370" id="srcline370">370</a></span><span class="line">            <span class="keyword">case</span> <span class="string">'egm96'</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,371" id="srcline371">371</a></span><span class="line">                <span class="var type0" id="S10T0U1053">model</span> = lower( <span class="var type0" id="S102T0U1056">str</span> );</span></span>
<span class="srcline"><span class="lineno"><a href="1,372" id="srcline372">372</a></span><span class="line">                <span class="var type0" id="S12T0U1059">datafile</span> = <span class="string">'geoidegm96grid.mat'</span>;</span></span>
<span class="srcline"><span class="lineno"><a href="1,373" id="srcline373">373</a></span><span class="line">            <span class="keyword">case</span> { <span class="string">'error'</span>, <span class="string">'warning'</span>, <span class="string">'none'</span> }</span></span>
<span class="srcline"><span class="lineno"><a href="1,374" id="srcline374">374</a></span><span class="line">                <span class="var type0" id="S11T0U1069">action</span> = lower( <span class="var type0" id="S102T0U1072">str</span> );</span></span>
<span class="srcline"><span class="lineno"><a href="1,375" id="srcline375">375</a></span><span class="line">            <span class="keyword">otherwise</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,376" id="srcline376">376</a></span><span class="line">                error(message(<span class="string">'aero:geoidheight:unknownString'</span>));</span></span>
<span class="srcline"><span class="lineno"><a href="1,377" id="srcline377">377</a></span><span class="line">        <span class="keyword">end</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,378" id="srcline378">378</a></span><span class="line">    <span class="keyword">end</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,379" id="srcline379">379</a></span><span class="line"><span class="comment">%=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,380" id="srcline380">380</a></span><span class="line"> <span class="keyword">function</span> checkegm2008( <span class="var type0" id="S109T0U1084">str</span> )    </span></span>
<span class="srcline"><span class="lineno"><a href="1,381" id="srcline381">381</a></span><span class="line">     <span class="keyword">if</span> strcmp(<span class="var type0" id="S109T0U1089">str</span>,<span class="string">'egm2008'</span>)</span></span>
<span class="srcline"><span class="lineno"><a href="1,382" id="srcline382">382</a></span><span class="line">         <span class="keyword">if</span> isempty(which(<span class="string">'geoidegm2008grid.mat'</span>,<span class="string">'-ALL'</span>))</span></span>
<span class="srcline"><span class="lineno"><a href="1,383" id="srcline383">383</a></span><span class="line">             error(message(<span class="string">'aero:geoidheight:noDownloadData'</span>,<span class="keyword">...</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,384" id="srcline384">384</a></span><span class="line">                 <span class="string">'&lt;a href="matlab: aeroDataPackage"&gt;aeroDataPackage&lt;/a&gt;'</span>))</span></span>
<span class="srcline"><span class="lineno"><a href="1,385" id="srcline385">385</a></span><span class="line">         <span class="keyword">end</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,386" id="srcline386">386</a></span><span class="line">     <span class="keyword">end</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,387" id="srcline387">387</a></span><span class="line"> <span class="keyword">end</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,388" id="srcline388">388</a></span><span class="line"><span class="comment">%=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-</span></span></span>
<span class="srcline"><span class="lineno"><a href="1,389" id="srcline389">389</a></span><span class="line"><span class="keyword">end</span></span></span>
</pre>
